

Page({
  data: {
    id: null,
    up_bin: null,
    down_bin: null
  },
  goto_bin(e) {
    let wei = e.currentTarget.dataset.wei;
    if (wei == 'up_bin') {
      wx.setStorageSync('bin_xia', this.data.up_bin);
    } else if (wei == 'down_bin') {
      wx.setStorageSync('bin_xia', this.data.down_bin);
    }
    wx.navigateTo({
      url: '/pages/HZ/HZ',
    })
  },
  getdata(value) {
    console.log(value)
    wx.cloud.database().collection('bin_inf').where({ bin_num: Number(value) }).get().then(res => {
      console.log(res)
      let up_bin, down_bin;
      if (res.data[0].bing_up) {
        up_bin = res.data[0];
      } else {
        down_bin = res.data[0];
      } if (res.data[1].bing_up) {
        up_bin = res.data[1];
      } else {
        down_bin = res.data[1];
      }
      this.setData({
        up_bin: up_bin,
        down_bin: down_bin
      })
    })
    wx.stopPullDownRefresh();
  },
  onLoad(option) {
    this.setData({ id: option.ids });
    this.getdata(option.ids)
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.getdata(this.data.id);
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getdata(this.data.id);
  },
})
